package demo;

import java.time.LocalDateTime;

import com.aerospike.client.IAerospikeClient;
import com.aerospike.client.Key;
import com.aerospike.client.Record;
import com.aerospike.client.policy.WritePolicy;

public class NoTTLTest {

	public static void main(String[] args) throws Exception {

		IAerospikeClient client = AsClientUtil.getClient();
		System.out.println("client=" + client);

		String namespace = "ns1";
		String dataSetName = "testset";
		String bin = "DATA";
		int ttl = 0;
		WritePolicy policy = new WritePolicy();
		policy.expiration = ttl;

		System.out.println("namespace=" + namespace);
		System.out.println("dataSetName=" + dataSetName);
		System.out.println("bin=" + bin);
		System.out.println("ttl=" + ttl);

		String key = "nottl";
		String value = key + "-" + LocalDateTime.now();
		AsClientUtil.put(client, policy, namespace, dataSetName, key, bin, value);

		System.out.println("NoTTLTest write done," + LocalDateTime.now());
		
		Key k = new Key(namespace, dataSetName, key);
		Record record = client.get(null, k);
		
		System.out.println("record=" + record);
		
		
		
		
		ttl=-1;
		policy.expiration = ttl;
		key = "nottl2";
		value = key + "-" + LocalDateTime.now();
		AsClientUtil.put(client, policy, namespace, dataSetName, key, bin, value);

		k = new Key(namespace, dataSetName, key);
		record = client.get(null, k);
		
		System.out.println("record=" + record);
		
		
		
		

		
		
		

	}

}
